package com.youkeda.yikao.web.validator;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author ：xiong
 * @date ：Created in 2019/10/7 22:52
 * @description：email
 * @modified By：
 */
public class EmailCodeValidator implements ConstraintValidator<EmailCode,String> {
    @Autowired
    private HttpServletRequest request;
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {

        String eamilCode= (String) request.getSession().getAttribute("emailCode");
        return StringUtils.equals(s,eamilCode);
    }
}
